﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Diagnostics;

namespace LowLevelGraphics.ColorSpaces
{
    /// <summary>
    /// sRGB Channel
    /// </summary>
    public enum sRGBChannel
    {
        /// <summary>
        /// 
        /// </summary>
        R = 0,
        /// <summary>
        /// 
        /// </summary>
        G = 1,
        /// <summary>
        /// 
        /// </summary>
        B = 2
    }

    [DebuggerDisplay("R: {m_fR}, G: {m_fG}, B: {m_fB}")]
    public class sRGB : AbstractColorSpace
    {
        protected float m_fR = 0.0f;
        protected float m_fG = 0.0f;
        protected float m_fB = 0.0f;

        /// <summary>
        /// Primary constructor
        /// </summary>
        public sRGB(Color _color)
            : base(_color)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="sRGB"/> class.
        /// </summary>
        /// <param name="_fR">The _f R.</param>
        /// <param name="_fG">The _f G.</param>
        /// <param name="_fB">The _f B.</param>
        public sRGB(float _fR, float _fG, float _fB)
        {
            m_fR = _fR;
            m_fG = _fG;
            m_fB = _fB;
        }

        /// <summary>
        /// this is used by clone to create a deep copy
        /// </summary>
        /// <param name="_sRGB"></param>
        internal sRGB(sRGB _sRGB)
        {
            this.m_fR = _sRGB.m_fR;
            this.m_fG = _sRGB.m_fG;
            this.m_fB = _sRGB.m_fB;
        }

        /// <summary>
        /// enables the caller to convert a color into sRGB
        /// </summary>
        /// <param name="_color"></param>
        /// <returns></returns>
        public static explicit operator sRGB(Color _color)
        {
            return new sRGB(_color);
        }

        /// <summary>
        /// Sets or gets R
        /// </summary>
        public float R
        {
            get { return m_fR; }
            set { m_fR = value; }
        }

        /// <summary>
        /// Gets or sets G
        /// </summary>
        public float G
        {
            get { return m_fG; }
            set { m_fG = value; }
        }

        /// <summary>
        /// Gets or sets B
        /// </summary>
        public float B
        {
            get { return m_fB; }
            set { m_fB = value; }
        }

        /// <summary>
        /// Used to convert color into this color space
        /// </summary>
        protected override void CalcValues()
        {
        }

        /// <summary>
        /// retransform color into rgb
        /// </summary>
        /// <returns></returns>
        public override Color ToColor()
        {
            return Color.FromArgb(0, 0, 0);
        }

        /// <summary>
        /// Gets the values.
        /// </summary>
        /// <returns></returns>
        public override object[] GetValues()
        {
            return new object[] { m_fR, m_fB, m_fG};
        }

        /// <summary>
        /// Sets the values.
        /// </summary>
        /// <param name="_aObject">The _a object.</param>
        /// <returns></returns>
        public override void SetValues(object[] _aObject)
        {
            this.m_fR = (float)_aObject[0];
            this.m_fG = (float)_aObject[1];
            this.m_fB = (float)_aObject[2];
        }

        /// <summary>
        /// used to create a deep copy
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new sRGB(this);
        }
    }
}
